#include "dsat.h"

namespace blacktip 
{
	AlgorithimDSAT::AlgorithimDSAT() 
	{
		numCompartments = NUM_COMPARTMENTS;

		compartments = new Compartment[NUM_COMPARTMENTS]
		{
			Compartment(COMPARTMENT_5MIN_HALFTIME, COMPARTMENT_5MIN_MVALUE),
			Compartment(COMPARTMENT_10MIN_HALFTIME, COMPARTMENT_10MIN_MVALUE),
			Compartment(COMPARTMENT_20MIN_HALFTIME, COMPARTMENT_20MIN_MVALUE),
			Compartment(COMPARTMENT_30MIN_HALFTIME, COMPARTMENT_30MIN_MVALUE),
			Compartment(COMPARTMENT_40MIN_HALFTIME, COMPARTMENT_40MIN_MVALUE),
			Compartment(COMPARTMENT_60MIN_HALFTIME, COMPARTMENT_60MIN_MVALUE),
			Compartment(COMPARTMENT_80MIN_HALFTIME, COMPARTMENT_80MIN_MVALUE),
			Compartment(COMPARTMENT_100MIN_HALFTIME, COMPARTMENT_100MIN_MVALUE),
			Compartment(COMPARTMENT_120MIN_HALFTIME, COMPARTMENT_120MIN_MVALUE),
			Compartment(COMPARTMENT_160MIN_HALFTIME, COMPARTMENT_160MIN_MVALUE),
			Compartment(COMPARTMENT_200MIN_HALFTIME, COMPARTMENT_200MIN_MVALUE),
			Compartment(COMPARTMENT_240MIN_HALFTIME, COMPARTMENT_240MIN_MVALUE),
			Compartment(COMPARTMENT_360MIN_HALFTIME, COMPARTMENT_360MIN_MVALUE),
			Compartment(COMPARTMENT_480MIN_HALFTIME, COMPARTMENT_480MIN_MVALUE)
		};
	}

	AlgorithimDSAT::~AlgorithimDSAT() 
	{
		delete [] compartments;
	}

	// TODO: not matching up correctly
	char AlgorithimDSAT::getPressureGroup() const
	{
		const double  PRESSURE_PER_GROUP = (compartments[COMPARTMENT_60MIN].getMValue() - SURFACE_PN2) / NUM_PRESSURE_GROUPS;
		int groupNumeric = (compartments[COMPARTMENT_60MIN].getPressureNitrogen() - SURFACE_PN2) / PRESSURE_PER_GROUP;

		if (groupNumeric > 26.0)
			groupNumeric = 26.0;

		return "ABCDEFGHIJKLMNOPQRSTUVWXYZ!"[groupNumeric];
	}

}